﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using T3Task5;

namespace chaoshiguanli
{
    public partial class Statistics : Form
    {
        public Statistics()
        {
            InitializeComponent();
        }

        private void toolStripTextBox1_Click(object sender, EventArgs e)
        {

        }
        //按商品统计
        private void button1_Click(object sender, EventArgs e)
        {
            listView1.Columns[0].Text = "商品名称";
            listView1.Columns[1].Text = "商品数量";
            listView1.Columns[2].Text = "单价";
            listView1.Columns[3].Text = "合计";
            listView1.Columns[4].Text = "销售单号";
            listView1.Columns[5].Text = "会员卡号";
            listView1.Columns[6].Text = "付款方式";
            listView1.Columns[7].Text = "操作员";
            listView1.Columns[8].Text = "班次";
            listView1.Columns[9].Text = "时间";
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity*UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //
            listView2.Columns[0].Text = "销售单号";
            listView2.Columns[1].Text = "商品编号";
            listView2.Columns[2].Text = "商品名称";
            listView2.Columns[3].Text = "商品数量";
            listView2.Columns[4].Text = "原价";
            listView2.Columns[5].Text = "售价";
            listView2.Columns[6].Text = "会员卡号";
            listView2.Columns[7].Text = "卡主姓名";
            listView2.Columns[8].Text = "折扣";
            listView2.Columns[9].Text = "总金额";
            listView2.Columns[10].Text = "时间";
            listView2.Columns[11].Text = "操作员";
            listView2.Columns[12].Text = "班次";
            listView2.Columns[13].Text = "备注";
            //数据库查询
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["Discout"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                float Discout = Convert.ToInt32(dt.Rows[0]["Discout"]);//折扣
                double a = UnitPrice*quantity;
                item.SubItems.Add((a*Discout).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["Note"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Statistics_Load(object sender, EventArgs e)
        {
            //数据库查询
            try
            {

                //定义查询数据库的SQL语句
                string sql = string.Format("select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sql);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["total"].ToString());
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                float total = Convert.ToInt32(dt.Rows[0]["total"]);
                float Payment = Convert.ToInt32(dt.Rows[0]["Payment"]);
                item.SubItems.Add((Payment - total).ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //
            try
            {

                //定义查询数据库的SQL语句
                string sql = string.Format("select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID ");
                DataTable dt = DBHelper.SelectAdapter(sql);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["goodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["Promotion"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity * UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
           
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
        //按会员
        private void button2_Click(object sender, EventArgs e)
        {
            listView1.Columns[0].Text = "会员卡号";
            listView1.Columns[1].Text = "卡主姓名";
            listView1.Columns[2].Text = "商品";
            listView1.Columns[3].Text = "商品数量";
            listView1.Columns[4].Text = "单价";
            listView1.Columns[5].Text = "付款方式";
            listView1.Columns[6].Text = "销售单号";
            listView1.Columns[7].Text = "操作员";
            listView1.Columns[8].Text = "班次";
            listView1.Columns[9].Text = "时间";
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity*UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                item.SubItems.Add(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //
            listView2.Columns[0].Text = "销售单号";
            listView2.Columns[1].Text = "会员卡号";
            listView2.Columns[2].Text = "卡主姓名";
            listView2.Columns[3].Text = "商品编号";
            listView2.Columns[4].Text = "商品名称";
            listView2.Columns[5].Text = "商品数量";
            listView2.Columns[6].Text = "原价";
            listView2.Columns[7].Text = "售价";
            listView2.Columns[8].Text = "折扣";
            listView2.Columns[9].Text = "总金额";
            listView2.Columns[10].Text = "时间";
            listView2.Columns[11].Text = "操作员";
            listView2.Columns[12].Text = "班次";
            listView2.Columns[13].Text = "备注";
            //数据库查询
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["Discout"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                float Discout = Convert.ToInt32(dt.Rows[0]["Discout"]);//折扣
                double a = UnitPrice*quantity;
                item.SubItems.Add((a*Discout).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["Note"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //按操作员
        private void button3_Click(object sender, EventArgs e)
        {
            listView1.Columns[0].Text = "操作员";
            listView1.Columns[1].Text = "班次";
            listView1.Columns[2].Text = "会员卡号";
            listView1.Columns[3].Text = "卡主姓名";
            listView1.Columns[4].Text = "商品";
            listView1.Columns[5].Text = "商品数量";
            listView1.Columns[6].Text = "单价";
            listView1.Columns[7].Text = "付款方式";
            listView1.Columns[8].Text = "销售单号";
            listView1.Columns[9].Text = "时间";
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity * UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                item.SubItems.Add(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //
            listView2.Columns[0].Text = "销售单号";
            listView2.Columns[1].Text = "操作员";
            listView2.Columns[2].Text = "班次";
            listView2.Columns[3].Text = "会员卡号";
            listView2.Columns[4].Text = "卡主姓名";
            listView2.Columns[5].Text = "商品编号";
            listView2.Columns[6].Text = "商品名称";
            listView2.Columns[7].Text = "商品数量";
            listView2.Columns[8].Text = "原价";
            listView2.Columns[9].Text = "售价";
            listView2.Columns[10].Text = "折扣";
            listView2.Columns[11].Text = "总金额";
            listView2.Columns[12].Text = "时间";
            listView2.Columns[13].Text = "备注";
            //数据库查询
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["Discout"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                float Discout = Convert.ToInt32(dt.Rows[0]["Discout"]);//折扣
                double a = UnitPrice * quantity;
                item.SubItems.Add((a * Discout).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Note"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //按班次
        private void button4_Click(object sender, EventArgs e)
        {

            listView1.Columns[0].Text = "班次";
            listView1.Columns[1].Text = "操作员";
            listView1.Columns[2].Text = "会员卡号";
            listView1.Columns[3].Text = "卡主姓名";
            listView1.Columns[4].Text = "商品";
            listView1.Columns[5].Text = "商品数量";
            listView1.Columns[6].Text = "单价";
            listView1.Columns[7].Text = "付款方式";
            listView1.Columns[8].Text = "销售单号";
            listView1.Columns[9].Text = "时间";
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity * UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                item.SubItems.Add(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //
            listView2.Columns[0].Text = "销售单号";
            listView2.Columns[1].Text = "班次";
            listView2.Columns[2].Text = "操作员";
            listView2.Columns[3].Text = "会员卡号";
            listView2.Columns[4].Text = "卡主姓名";
            listView2.Columns[5].Text = "商品编号";
            listView2.Columns[6].Text = "商品名称";
            listView2.Columns[7].Text = "商品数量";
            listView2.Columns[8].Text = "原价";
            listView2.Columns[9].Text = "售价";
            listView2.Columns[10].Text = "折扣";
            listView2.Columns[11].Text = "总金额";
            listView2.Columns[12].Text = "时间";
            listView2.Columns[13].Text = "备注";
            //数据库查询
            try
            {
                string sqlin = string.Format(" select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sqlin);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["Discout"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                float Discout = Convert.ToInt32(dt.Rows[0]["Discout"]);//折扣
                double a = UnitPrice * quantity;
                item.SubItems.Add((a * Discout).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Note"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
        //汇总按钮
        private void button5_Click(object sender, EventArgs e)
        {
            //数据库查询
            try
            {

                //定义查询数据库的SQL语句
                string sql = string.Format("select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sql);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["total"].ToString());
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                float total = Convert.ToInt32(dt.Rows[0]["total"]);
                float Payment = Convert.ToInt32(dt.Rows[0]["Payment"]);
                item.SubItems.Add((Payment - total).ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //
            try
            {

                //定义查询数据库的SQL语句
                string sql = string.Format("select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sql);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["goodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["Promotion"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity * UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void toolStripComboBox3_Click(object sender, EventArgs e)
        {

        }
        //查询按钮
        private void button6_Click(object sender, EventArgs e)
        {
            //数据库查询
            try
            {

                //定义查询数据库的SQL语句
                string sql = string.Format("select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsIDand and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sql);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                item.SubItems.Add(dt.Rows[0]["total"].ToString());
                item.SubItems.Add(dt.Rows[0]["PaymentMethod"].ToString());
                float total = Convert.ToInt32(dt.Rows[0]["total"]);
                float Payment = Convert.ToInt32(dt.Rows[0]["Payment"]);
                item.SubItems.Add((Payment-total).ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                listView1.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //
            try
            {

                //定义查询数据库的SQL语句
                string sql = string.Format("select  *   from Ordersdetail o, OrdersdetailID r,Employee e, Menber m,Goods g where o.ordersID = r.ordersID and o.NumberID = m.NumberID and o.WorkNumberID = e.WorkNumberID and r.goodsID = g.GoodsID and Timee between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
                DataTable dt = DBHelper.SelectAdapter(sql);
                ListViewItem item = new ListViewItem(dt.Rows[0]["ordersID"].ToString());
                item.SubItems.Add(dt.Rows[0]["goodsID"].ToString());
                item.SubItems.Add(dt.Rows[0]["GoodsName"].ToString());
                item.SubItems.Add(dt.Rows[0]["Originalprice"].ToString());
                item.SubItems.Add(dt.Rows[0]["Promotion"].ToString());
                item.SubItems.Add(dt.Rows[0]["UnitPrice"].ToString());
                item.SubItems.Add(dt.Rows[0]["quantity"].ToString());
                float quantity = Convert.ToInt32(dt.Rows[0]["quantity"]);//商品数量
                float UnitPrice = Convert.ToInt32(dt.Rows[0]["UnitPrice"]);//商品单价
                item.SubItems.Add((quantity * UnitPrice).ToString("f2"));//合计
                item.SubItems.Add(dt.Rows[0]["NumberID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Name"].ToString());
                item.SubItems.Add(dt.Rows[0]["NameID"].ToString());
                item.SubItems.Add(dt.Rows[0]["Timee"].ToString());
                item.SubItems.Add(dt.Rows[0]["Shif"].ToString());
                listView2.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {

        }
    }
}
